//
//  UIView+Extension.h
//  欢迎界面
//
//  Created by 孟瑞瑞 on 15/9/11.
//  Copyright (c) 2018年 CSDN. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface UIView (Extension)
@property (nonatomic)CGFloat width;
@property (nonatomic)CGFloat height;
@property (nonatomic)CGFloat x;
@property (nonatomic)CGFloat y;

@property (nonatomic)CGSize size;
@property (nonatomic)CGPoint origin;

@property (nonatomic, assign) CGFloat centerX;
@property (nonatomic, assign) CGFloat centerY;

@property (nonatomic, assign, readonly) CGFloat maxX;
@property (nonatomic, assign, readonly) CGFloat maxY;

/**
 快速给View添加4边阴影
 参数:阴影透明度，默认0
 */
- (void)addProjectionWithShadowOpacity:(CGFloat)shadowOpacity;
/**
 快速给View添加4边框
 参数:边框宽度
 */
- (void)addBorderWithWidth:(CGFloat)width;
/**
 快速给View添加4边框
 width:边框宽度
 borderColor:边框颜色
 */
- (void)addBorderWithWidth:(CGFloat)width borderColor:(UIColor *)borderColor;
/**
 快速给View添加圆角
 参数:圆角半径
 */
- (void)addRoundedCornersWithRadius:(CGFloat)radius;
/**
 快速给View添加圆角
 radius:圆角半径
 corners:且那几个角
 类型共有以下几种:
 typedef NS_OPTIONS(NSUInteger, UIRectCorner) {
 UIRectCornerTopLeft,
 UIRectCornerTopRight ,
 UIRectCornerBottomLeft,
 UIRectCornerBottomRight,
 UIRectCornerAllCorners
 };
 使用案例:[self.mainView addRoundedCornersWithRadius:10 byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight]; // 切除了左下 右下
 */
- (void)addRoundedCornersWithRadius:(CGFloat)radius byRoundingCorners:(UIRectCorner)corners;

- (BOOL)isDisplayedInScreen;

// 递归获取子视图
- (UIView *)getSub:(NSString *)viewClassName andLevel:(int)level;

/**
 绘制圆角矩形
 
 @param size 画布大小
 @param borderColor 边缘颜色
 @param borderRadius 圆角半径
 @param borderWidth 线宽
 @param margin 上下左右间距
 */
+ (instancetype)roundRectImageWithFrame:(CGSize)size
                            borderColor:(UIColor *)borderColor
                           borderRadius:(CGFloat)borderRadius
                            borderWidth:(CGFloat)borderWidth
                                 margin:(CGFloat)margin;


/**
给view添加旋转动画

 @param view
 @param duration 多久转一圈
 */
- (void)addTranstionAnimation:(UIView *)view duration:(CGFloat)duration;

- (void)addTapGestureWithTarget:(id)target action:(SEL)action;
- (void)addTapGestureWithBlock:(void (^)(UIView *gestureView))aBlock;
- (void)removeTapGesture;
- (void)addTapWithGestureBlock:(void (^)(UITapGestureRecognizer *gesture))aBlock;
- (void)addTapWithDelegate:(id<UIGestureRecognizerDelegate>)delegate gestureBlock:(void (^)(UITapGestureRecognizer *gesture))aBlock;
@end
